home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Magazine / Online / OpenURL / Developer / Source / Example.c < prev    next >
C/C++ Source or Header  |  1999-09-26  |  2KB  |  63 lines

  1. /*
  2. ** Example - test app for openurl.library
  3. ** Written by Troels Walsted Hansen <troels@thule.no>
  4. ** Placed in the public domain.
  5. **
  6. ** This is the one and only source file.
  7. */
  8.  
  9. #include <proto/exec.h>
  10. #include <proto/dos.h>
  11. #include <proto/openurl.h>
  12.  
  13. #include <dos/dos.h>
  14. #include <libraries/openurl.h>
  15.  
  16. static const char *version = "$VER: Example 1.2 " __AMIGADATE__;
  17. #define ARGS "URL,SHOW/S,TOFRONT/S,NEWWIN/S,LAUNCH/S,LAUNCHPREFS/S"
  18. enum { A_URL, A_SHOW, A_TOFRONT, A_NEWWIN, A_LAUNCH, A_LAUNCHPREFS, A_MAX };
  19. struct Library *OpenURLBase;
  20.  
  21. int main(void)
  22. {
  23.     int retval = RETURN_FAIL;
  24.  
  25.     if((OpenURLBase = OpenLibrary("openurl.library", 1)))
  26.     {
  27.         LONG args[A_MAX] = {0};
  28.         struct RDArgs *rda;
  29.  
  30.         if((rda = ReadArgs(ARGS, args, NULL)))
  31.         {
  32.             if(args[A_LAUNCHPREFS])
  33.             {
  34.                 if(OpenURLBase->lib_Version < 3)
  35.                     Printf("LAUNCHPREFS requires openurl.library V3+\n");
  36.                 else
  37.                 {
  38.                     URL_LaunchPrefsApp();
  39.                     retval = RETURN_OK;
  40.                 }
  41.             }
  42.             else if(args[A_URL])
  43.             {
  44.                 if(URL_Open((STRPTR)args[A_URL], URL_Show,         args[A_SHOW],
  45.                                                  URL_BringToFront, args[A_TOFRONT],
  46.                                                  URL_NewWindow,    args[A_NEWWIN],
  47.                                                  URL_Launch,       args[A_LAUNCH],
  48.                                                  TAG_DONE))
  49.                     retval = RETURN_OK;
  50.             }
  51.             else Printf("Either URL or LAUNCHPREFS must be specifed\n");
  52.  
  53.             FreeArgs(rda);
  54.         }
  55.         else PrintFault(IoErr(), "Failed to parse arguments");
  56.  
  57.         CloseLibrary(OpenURLBase);
  58.     }
  59.     else Printf("Requires openurl.library V1+\n");
  60.  
  61.     return(retval);
  62. }
  63.